package kt03

import kotlin.concurrent.thread

fun main() {
    listOf("AAA", "BBB", "CCC").forEach {
        println(it)
    }
    listOf("AAA", "BBB", "CCC").mForEach {
        println(it)
    }
    val b = "DDD".mLet {
        println("我的值是$it")
        false
    }
    println(b)

    println("DDD".take(1))
    println("DDD".takeIf { it.length > 5 })
    var i = 0
    thread {
        while (i < 10) {
            println("我是异步线程$i")
            i++
        }
    }

}

private inline fun <T> Iterable<T>.mForEach(lambda: (T) -> Unit) = kotlin.run {
    for (item in this) lambda.invoke(item)
}

private inline fun <I, O> I.mLet(lambda: (I) -> O) = lambda.invoke(this)